<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="footer.css" />
		<link rel="stylesheet" href="../../css/lystyle.css" />
		<style type="text/css">
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
			
			.ly-line {
				margin: 5px 0.69444rem;
				height: 1px;
				background: #DEDEDE;
			}
			
			.ly-info li {
				box-shadow: 0.069444rem 0.069444rem 0.069444rem #b3b3b3;
				margin-bottom: 0.277777rem;
				border-top: 0.013888rem solid #f8f8f8;
			}
			.ly-info2 li {
				box-shadow: 0.069444rem 0.069444rem 0.069444rem #b3b3b3;
				margin-bottom: 0.277777rem;
				border-top: 0.013888rem solid #f8f8f8;
			}
			.ly-info3 li {
				box-shadow: 0.069444rem 0.069444rem 0.069444rem #b3b3b3;
				margin-bottom: 0.277777rem;
				border-top: 0.013888rem solid #f8f8f8;
			}
			.ly-info {
				border: 0;
			}
			
			.ly-nav-active {
				color: #e83023;
			}
			
			.ly-nav-active:hover {
				color: #e83023;
			}
			.red_border{
				border-bottom: 1px solid red;
			}
			.btn_info{
				border-radius: 10px; padding:5px;border: 0;background-color:red;color:#fff; border:none;
			}
		</style>
		<script src="../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../images/12.png" /></a>
					<p id="headTitle">我的订单</p>
				</div>
				<div id="ly-nav" class="row">
					<div id="orderAll" class="ly-nav ly-nav-active col-xs-4 col-sm-4">
						<span id="type1" class="ly-font16 red_border" style="padding-bottom: 0.2rem;">待支付</span>
					</div>
					<div id="orderPay" class="ly-nav col-xs-4 col-sm-4">
						<span  id="type2"class="ly-font16" style="padding-bottom: 0.2rem;">已付款</span>
					</div>
					<div id="orderCancel" class="ly-nav col-xs-4 col-sm-4">
						<span id="type3" class="ly-font16" style="padding-bottom: 0.2rem;">已取消</span>
					</div>
				</div>
				<!--内容-->
				<div id="content">
					<!--全部-->
					<ul class="ly-info">
						
					</ul>
				</div>
				<div id="content2">
					<!--全部-->
					<ul class="ly-info2">
						
					</ul>
				</div>
				<div id="content3">
					<!--全部-->
					<ul class="ly-info3">
						
					</ul>
				</div>
			</div>
		</div>
		<form id="wxForm" name="wxForm" method="post"></form>
	</body>
	<script src="../../js/jquery-2.2.3.min.js"></script>
	<script src="../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
	//	var tokenReztApp = $.cookie("tokenReztApp");
	//	if(!tokenReztApp) {
	//		window.location.href = "../login/login/login.html";
	//	}
		$(function() {
	//		currentyf();
		});
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: true,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../login/login/login.html";
				},
				success: function(data) {
					/*if(data.roleList[0].id != "f2") {
						window.location.href = "../../app/view/login/login/login.html";
					}*/
					/*	user = data.loginName;
						roles = data.roleList; //角色集合
						goodsId = data.id;*/

				}
			});
		}
		function cancel(orderSn){
				//alert(orderSn)
				$.ajax({
					type: "get",
					url: "http://47.104.13.109:80/mall-service/cancel?orderSn="+orderSn,
					async: true,
					success: function(res2) {
						alert("取消成功!");
						ajax();
					}
				});
			}
		function zhifu(orderSn){
				$.get("http://47.104.13.109/pay-service/getOpenId?memberId="+$.cookie("memberId")+"&orderSn="+orderSn, {
					rediretUrl:location.href
				}, function(data) {
					if(data != ""){
						$("#wxForm").prop("action",data.url);
						$("#wxForm").submit();
					}	
				},"json");
			}
		$(document).ready(function() {
			$(".ly-nav").click(function() {
				$('.ly-nav').removeClass('ly-nav-active');
				$(this).addClass('ly-nav-active');
			});
			var userName = null;
			var orderStatus = 1;
			var siid = null;
			console.log($.cookie('tokenRh'));

			//获取会员信息
			$.ajax({
				type: "get",
				url: "http://47.104.13.109/member-service/auth/current?token=" + $.cookie('tokenRh'),
				async: true,
				success: function(data) {
					console.log(data);
					siid = data.id;
					ajax();
					ajax2();
					ajax3();
				}
			});
			
			});

			function ajax() {
				$.ajax({
					type: "get",
					url: "http://47.104.13.109:80/mall-service/order/list?pageNum=1&pageSize=10&orderStatus=0&memberId="+$.cookie("memberId"),
					async: true,
					success: function(res2) {
						console.log(res2);
						var str = '';
						for(var i=0;i<res2.size;i++){
							//获取商家信息
							str += '<li><div class="ly_storeinfo ly-color7D"><p style="line-height:20px; padding-top:10px;"><img src="../../images/personage/store.png"/><span style="font-size: 14px;"><b>商店名称：</b></span><span>'+res2.list[i].shopName+'</span></p><p style="line-height:20px;"><img src="../../images/personage/category.png"/><span style="font-size: 14px;">类型：</span><span>'+res2.list[i].classifyTwo+'</span></p><p style="line-height:20px;"><img src="../../images/personage/order.png"/><span style="font-size: 14px;">订单编号：</span><span>'+res2.list[i].orderSn+'</span></p><p style="line-height:20px;"><span style="font-size: 14px;">下单时间：</span><span>'+res2.list[i].orderDate+'</span></p><p style="line-height:20px;"><img src="../../images/personage/address.png"/><span style="font-size: 14px;">商家地址：</span><span>'+res2.list[i].shopLocation+'</span></p></div><div class="ly-line"></div><div class="ly_shop ly-color7D" style="padding-bottom: 4px;"><p style="line-height:20px;"><span style="font-size: 14px;">消费仁和币金额：</span><span>' + res2.list[i].orderCoinrh + '</span></p><p style="line-height:20px;"><span style="font-size: 14px;">消费现金：</span><span>'+res2.list[i].orderNum+'</span></p><p style="line-height:20px;"><a class="btn_info"  style="margin-left:0.5rem"; onclick="cancel(\'' + res2.list[i].orderSn + '\')">取消订单</a>&nbsp;&nbsp;<a onclick="zhifu(\'' + res2.list[i].orderSn + '\')" class="btn_info">立即支付</a></li>';
							$('.ly-info').html(str);
						}			
						
					}
				});
			}

			function ajax2() {
				$.ajax({
					type: "get",
					url: "http://47.104.13.109:80/mall-service/order/list?pageNum=1&pageSize=10&orderStatus=1&memberId="+$.cookie("memberId"),
					async: true,
					success: function(res2) {
						console.log(res2);
						var str = '';
						for(var i=0;i<res2.size;i++){
							//获取商家信息
							/*if(i == 0){
								str += '<li style="background:#fff;"><div class="ly_storeinfo ly-color7D"><p style="line-height:20px; padding-top:10px;"><img src="../../images/personage/store.png"/><span style="font-size: 14px;"><b>商店名称：</b></span><span>'+res2.list[i].shopName+'</span></p><p style="line-height:20px;"><img src="../../images/personage/category.png"/><span style="font-size: 14px;">类型：</span><span>'+res2.list[i].classifyTwo+'</span></p><p style="line-height:20px;"><img src="../../images/personage/order.png"/><span style="font-size: 14px;">订单编号：</span><span>'+res2.list[i].orderSn+'</span></p><p style="line-height:20px;"><span style="font-size: 14px;">支付时间：</span><span>'+res2.list[i].payDate+'</span></p><p style="line-height:20px;"><img src="../../images/personage/address.png"/><span style="font-size: 14px;">商家地址：</span><span>'+res2.list[i].shopLocation+'</span></p></div><div class="ly-line"></div><div class="ly_shop ly-color7D" style="padding-bottom: 4px;"><p style="line-height:20px;"><span style="font-size: 14px;">消费仁和币金额：</span><span>' + res2.list[i].orderCoinrh + '</span></p><p style="line-height:20px;"><span style="font-size: 14px;">消费现金：</span><span>'+res2.list[i].orderNum+'</span></p><p style="line-height:20px;"><span style="font-size: 14px;">我的评论：</span>&nbsp;&nbsp;&nbsp;<span>这是啥玩意！</span></p><p style="line-height:20px;"><span style="font-size: 14px;">商家回复：</span>&nbsp;&nbsp;&nbsp;<span>擦，你懂不懂，不懂就别下单！</span></p></li>';
							}else{
								str += '<li  style="background:#fff;><div style="width:0.4rem;" class="ly_storeinfo ly-color7D"><p style="line-height:20px; padding-top:10px;"><img src="../../images/personage/store.png"/><span style="font-size: 14px;"><b>商店名称：</b></span><span>'+res2.list[i].shopName+'</span></p><p style="line-height:20px;"><img src="../../images/personage/category.png"/><span style="font-size: 14px;">类型：</span><span>'+res2.list[i].classifyTwo+'</span></p><p style="line-height:20px;"><img src="../../images/personage/order.png"/><span style="font-size: 14px;">订单编号：</span><span>'+res2.list[i].orderSn+'</span></p><p style="line-height:20px;"><span style="font-size: 14px;">支付时间：</span><span>'+res2.list[i].payDate+'</span></p><p style="line-height:20px;"><img src="../../images/personage/address.png"/><span style="font-size: 14px;">商家地址：</span><span>'+res2.list[i].shopLocation+'</span></p></div><div class="ly-line"></div><div class="ly_shop ly-color7D" style="padding-bottom: 4px;"><p style="line-height:20px;"><span style="font-size: 14px;">消费仁和币金额：</span><span>' + res2.list[i].orderCoinrh + '</span></p><p style="line-height:20px;"><span style="font-size: 14px;">消费现金：</span><span>'+res2.list[i].orderNum+'</span></p><p style="line-height:20px;"><span style="font-size: 14px;"><button class="btn_info">立即评价</button></span></p></li>';
							}*/
							str += '<li style="background:#fff;"><div class="ly_storeinfo ly-color7D"><p style="line-height:20px; padding-top:10px;"><img src="../../images/personage/store.png"/><span style="font-size: 14px;"><b>商店名称：</b></span><span>'+res2.list[i].shopName+'</span></p><p style="line-height:20px;"><img src="../../images/personage/category.png"/><span style="font-size: 14px;">类型：</span><span>'+res2.list[i].classifyTwo+'</span></p><p style="line-height:20px;"><img src="../../images/personage/order.png"/><span style="font-size: 14px;">订单编号：</span><span>'+res2.list[i].orderSn+'</span></p><p style="line-height:20px;"><span style="font-size: 14px;">支付时间：</span><span>'+res2.list[i].payDate+'</span></p><p style="line-height:20px;"><img src="../../images/personage/address.png"/><span style="font-size: 14px;">商家地址：</span><span>'+res2.list[i].shopLocation+'</span></p></div><div class="ly-line"></div><div class="ly_shop ly-color7D" style="padding-bottom: 4px;"><p style="line-height:20px;"><span style="font-size: 14px;">消费仁和币金额：</span><span>' + res2.list[i].orderCoinrh + '</span></p><p style="line-height:20px;"><span style="font-size: 14px;">消费现金：</span><span>'+res2.list[i].orderNum+'</span></p></li>';
							$('.ly-info2').html(str);
											
						}
					}
				});
			}

			function ajax3() {
				$.ajax({
					type: "get",
					url: "http://47.104.13.109:80/mall-service/order/list?pageNum=1&pageSize=10&orderStatus=-1&memberId="+$.cookie("memberId"),
					async: true,
					success: function(res2) {
						console.log(res2);
						var str = '';
						for(var i=0;i<res2.size;i++){
							//获取商家信息
							str += '<li  style="background:#fff";><div class="ly_storeinfo ly-color7D"><p style="line-height:20px; padding-top:10px;"><img src="../../images/personage/store.png"/><span style="font-size: 14px;"><b>商店名称：</b></span><span>'+res2.list[i].shopName+'</span></p><p style="line-height:20px;"><img src="../../images/personage/category.png"/><span style="font-size: 14px;">类型：</span><span>'+res2.list[i].classifyTwo+'</span></p><p style="line-height:20px;"><img src="../../images/personage/order.png"/><span style="font-size: 14px;">订单编号：</span><span>'+res2.list[i].orderSn+'</span></p><p style="line-height:20px;"><span style="font-size: 14px;">下单时间：</span><span>'+res2.list[i].orderDate+'</span></p><p style="line-height:20px;"><img src="../../images/personage/address.png"/><span style="font-size: 14px;">商家地址：</span><span>'+res2.list[i].shopLocation+'</span></p></div><div class="ly-line"></div><div class="ly_shop ly-color7D" style="padding-bottom: 4px;"><p style="line-height:20px;"><span style="font-size: 14px;">消费仁和币金额：</span><span>' + res2.list[i].orderCoinrh + '</span></p><p style="line-height:20px;"><span style="font-size: 14px;">消费现金：</span><span>'+res2.list[i].orderNum+'</span></p></li>';
							$('.ly-info3').html(str);
						}				
					}
				});
			}
			
			
			$(document).on('click', "#orderAll", function() {
				$('#type1').addClass('active_red');
				$('#type2').removeClass('active_red');
				$('#type3').removeClass('active_red');
				$('#type2').removeClass('red_border');
				$('#type3').removeClass('red_border');
				$('#type1').addClass('red_border');
				document.getElementById("content").style.display="";
				document.getElementById("content2").style.display="none";
				document.getElementById("content3").style.display="none";
			});
			$("#orderPay").on('click', function() {
				$('#type2').addClass('active_red');
				$('#type1').removeClass('active_red');
				$('#type3').removeClass('active_red');
				$('#type2').addClass('red_border');
				$('#type1').removeClass('red_border');
				$('#type3').removeClass('red_border');
				document.getElementById("content").style.display="none";
				document.getElementById("content2").style.display="";
				document.getElementById("content3").style.display="none";
			});
			$("#orderCancel").on('click', function() {
				$('#type3').addClass('active_red');
				$('#type2').removeClass('active_red');
				$('#type1').removeClass('active_red');
				$('#type3').addClass('red_border');
				$('#type1').removeClass('red_border');
				$('#type2').removeClass('red_border');
				document.getElementById("content").style.display="none";
				document.getElementById("content2").style.display="none";
				document.getElementById("content3").style.display="";
			});

		
	</script>

</html>